local luoqiu = fk.CreateSkill {
  name = "th_luoqiu",
}

luoqiu:addEffect("viewas", {
  pattern = "slash",
  anim_type = "offensive",
  prompt = "#th_luoqiu",
  mute_card = false,
  handly_pile = true,
  card_num = 1,
  card_filter = function(self, player, to_select, selected)
    return #selected < 1 and Fk:getCardById(to_select).color == Card.Red
  end,
  view_as = function(self, player,cards)
    if #cards < 1 then return end
    local card = Fk:cloneCard(self.pattern)
    card.skillName = luoqiu.name
    card:addSubcards(cards)
    return card
  end,
  after_use = function(self, player, use)
    player.room:addPlayerMark(player, MarkEnum.MinusMaxCardsInTurn, 1)
  end,
  enabled_at_play = function(self, player)
    return player:getMaxCards() > 0 and player.phase == Player.Play and not player:isNude()
  end,
  enabled_at_response = Util.FalseFunc,
})
luoqiu:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card, to)
    return card and table.contains(card.skillNames, luoqiu.name)
  end
})
luoqiu:addEffect(fk.Damaged, {
  can_refresh = function(self, event, target, player, data)
    return target:isAlive() and data.from == player and target ~= player and player:hasSkill(luoqiu.name) and
    data.card and data.card.trueName == "slash" and table.contains(data.card.skillNames, luoqiu.name)
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(target, "@th_luoqiu", 1)
  end,
})
luoqiu:addEffect(fk.TurnEnd, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@th_luoqiu") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(target, "@th_luoqiu", 0)
  end,
})
luoqiu:addEffect("maxcards", {
  correct_func = function(self, player)
    return 0 - player:getMark("@th_luoqiu")
  end
})

Fk:loadTranslationTable{
  ["th_luoqiu"] = "落秋",
  [":th_luoqiu"] = "出牌阶段，若你的手牌上限大于0，你可以将红色牌当无次数限制的【杀】使用，然后你本回合的手牌上限-1，受到此【杀】伤害的角色手牌上限-1直到其回合结束。",
  ["#th_luoqiu"] = "落秋：将红色牌当无次数限制的【杀】使用，然后你本回合的手牌上限-1，<br>受到此【杀】伤害的角色手牌上限-1直到其回合结束",

  ["@th_luoqiu"] = "落秋",
}

return luoqiu